<?php 
// You have set the rules for rewrite and decode URL as pair.
$rewirtes=array(
	'/(\w+)\/(\w+)\&(\w+)=(\d+)\&(\w+)=(\d+)/'  => '${1}/${2}/${3}/${4}/${5}/${6}',
	'/(\w+)\/(\w+)\/(\w+)\&(\w+)=(\d+)/'  => '${1}/${2}/${3}/${4}/${5}',
	'/(\w+)\/(\w+)\&(\w+)=(\d+)/'  => '${1}/${2}/${3}/${4}',
	'/(\w+)\/(\w+)/'  => '${1}/${2}',
	'/(\w+)\/(\w+)\/(\w+)/'  => '${1}/${2}/${3}',
	'/(\w+)&(\w+)=(\d+)/'  => '${1}/${2}/${3}',
	'/(\w+)/'  => '${1}'
);

$decodes=array(
	'/(\w+)\/(\w+)\/(\w+)\/(\d+)\/(\w+)\/(\d+)/'  => '${1}/${2}&${3}=${4}&${5}=${6}',
	'/(\w+)\/(\w+)\/(\w+)\/(\w+)\/(\d+)/'  => '${1}/${2}/${3}&${4}=${5}',
	'/(\w+)\/(\w+)\/(\w+)\/(\d+)/'  => '${1}/${2}&${3}=${4}',
	'/(\w+)\/(\w+)/'  => '${1}/${2}',
	'/(\w+)\/(\w+)\/(\w+)/'  => '${1}/${2}/${3}',
	'/(\w+)\/(\w+)\/(\d+)/'  => '${1}&${2}=${3}',
	'/(\w+)/'  => '${1}'
);